package com.qhhc.service.impl;

import com.qhhc.entity.CarAppointment;
import com.qhhc.mapper.CarAppointmentMapper;
import com.qhhc.service.ICarAppointmentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class CarAppointmentServiceImpl implements ICarAppointmentService {

    @Autowired
    private CarAppointmentMapper carAppointmentMapper;

    @Override
    public List<CarAppointment> getAllAppointments() {
        List<CarAppointment> carAppointments = carAppointmentMapper.selectAllAppointments();
        for (CarAppointment carAppointment : carAppointments) {
            System.out.println(carAppointment);
        }

        return carAppointments;


    }

    @Override
    public CarAppointment getAppointmentById(Long id) {
        return carAppointmentMapper.selectAppointmentById(id);
    }

    @Override
    public List<CarAppointment> getAppointmentsByUserId(Long userId) {
        return carAppointmentMapper.selectAppointmentsByUserId(userId);
    }

    @Override
    public List<CarAppointment> getAppointmentsByCarId(Long carId) {
        return carAppointmentMapper.selectAppointmentsByCarId(carId);
    }

    @Override
    public List<CarAppointment> getAppointmentsByDealerId(Long dealerId) {
        return carAppointmentMapper.selectAppointmentsByDealerId(dealerId);
    }

    @Override
    public List<CarAppointment> getAppointmentsByStatus(String status) {
        return carAppointmentMapper.selectAppointmentsByStatus(status);
    }

    @Override
    public List<CarAppointment> searchAppointments(Map<String, Object> params) {
        return carAppointmentMapper.searchAppointments(params);
    }

    @Override
    public int addAppointment(CarAppointment appointment) {
        return carAppointmentMapper.insertAppointment(appointment);
    }

    @Override
    public int updateAppointment(CarAppointment appointment) {
        return carAppointmentMapper.updateAppointment(appointment);
    }

    @Override
    public int updateAppointmentStatus(Long id, String status) {
        return carAppointmentMapper.updateAppointmentStatus(id, status);
    }

    @Override
    public int deleteAppointment(Long id) {
        return carAppointmentMapper.deleteAppointment(id);
    }

    @Override
    public int deleteAppointmentsByCarId(Long carId) {
        return carAppointmentMapper.deleteAppointmentsByCarId(carId);
    }
} 